public class Test1 {
    //leetcode 860 柠檬水找零
    public boolean lemonadeChange(int[] bills) {
        int five = 0, ten = 0;
        for (int n : bills) {
            if (n == 5) five++;
            else if (n == 10) {
                if (five != 0) {
                    ten++;
                    five--;
                }else return false;
            }else {
                if (ten != 0 && five != 0) {
                    ten--;
                    five--;
                }else if (five >= 3) five -= 3;
                else return false;
            }
        }
        return true;
    }
}
